"""This module allows posting messages to a wordpress blog"""

import xmlrpclib


class WordPressPost:
    def __init__(self, user, password, domain):
        self.user = user
        self.password = password
        self.domain = domain

    def publishPost(self, title, description, **kargs ):
        server = xmlrpclib.ServerProxy('http://%s/xmlrpc.php' % self.domain)

        blog_id = 0

        blog_content = { 'title' : title, 'description' : description }
        blog_content.update(kargs)
        post_id = int(server.metaWeblog.newPost(blog_id, self.user, self.password, blog_content, 1))
        return post_id
